package com.haodai.vip.tomcat.utils;

import java.io.ByteArrayOutputStream;
import java.util.zip.GZIPOutputStream;

/**
 * Created by huangtao on 17/6/19.
 */
public class GzipUtils {

    public static byte[] zip(String content){
        try {
            byte[] buf = content.getBytes();
            ByteArrayOutputStream bos=new ByteArrayOutputStream();
            GZIPOutputStream gout=new GZIPOutputStream(bos);
            gout.write(buf);
            gout.close();
            return bos.toByteArray();
        } catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

}
